package cn.itcast.service.cargo.impl;

import cn.itcast.dao.cargo.InvoiceDao;
import cn.itcast.domain.cargo.Invoice;
import cn.itcast.domain.cargo.InvoiceExample;
import cn.itcast.service.cargo.InvoiceService;
import cn.itcast.vo.ShippingOrder;
import cn.itcast.vo.invoice;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class InvoiceServiceImpl implements InvoiceService {

    @Autowired
    private InvoiceDao invoiceDao;

    @Override
    public PageInfo<Invoice> findAll(InvoiceExample example, Integer page, Integer pageSize) {
        PageHelper.startPage(page, pageSize);
        List<Invoice> list = invoiceDao.selectByExample(example);
        return new PageInfo<Invoice>(list, 5);
    }

    @Override
    public void deleteById(String id) {
        invoiceDao.deleteByPrimaryKey(id);
    }

    @Override
    public void insertinvoice(Invoice invoice) {
        invoiceDao.insert(invoice);
    }

    @Override
    public Invoice findById(String id) {
        return invoiceDao.selectByPrimaryKey(id);
    }


    /*
    @Override
    public PageInfo<Invoice> findAll(InvoiceExample example, Integer page, Integer pageSize) {
        PageHelper.startPage(page, pageSize);
        List<Invoice> list = invoiceDao.selectByExample(example);
        return new PageInfo<Invoice>(list, 5);
    }


    @Override
    public Invoice findById(InvoiceExample example) {
        return invoiceDao.selectByExample(example).get(0);
    }

    @Override
    public void deleteById(InvoiceExample example) {
        invoiceDao.deleteByExample(example);
    }

    @Override
    public List<invoice> findinvoiceById(String id) {
//        invoiceDao.insertSelective()
        return invoiceDao.findinvoiceById(id);
    }



    @Override
    public List<ShippingOrder> findByShipping(String SHIPPING_ORDER_ID) {
        return invoiceDao.findByShipping(SHIPPING_ORDER_ID);
    }

    @Override
    public void insertinvoice(Invoice invoice) {
        invoiceDao.insert(invoice);
    }*/
}
